package com.hardydou.data.service.impl;

import com.hardydou.common.result.ResultAssert;
import com.hardydou.data.mapper.YdIconMapper;
import com.hardydou.data.mapper.YdTagMapper;
import com.hardydou.data.model.YdIcon;
import com.hardydou.data.model.YdTag;
import com.hardydou.data.service.IYdTagService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

/**
 * @author ：hardy
 * @description：
 * @date ：Created in 2021/1/31
 * @Copyright ：Hardydou.com
 */
@Service
public class YdTagServiceImpl implements IYdTagService {

    @Autowired
    YdTagMapper tagMapper;

    @Override
    public YdTag add(YdTag tag) {
        ResultAssert.notNull(tag);
        tagMapper.insert(tag);
        return tag;
    }

    @Override
    public YdTag update(YdTag tag) {
        tagMapper.updateByPrimaryKeySelective(tag);
        return tag;
    }

    @Override
    public YdTag findById(Long tagId) {
        return tagMapper.selectByPrimaryKey(tagId);
    }

    @Override
    public void delete(Long tagId) {
        YdTag obj = new YdTag();
        obj.setTagId(tagId);
        tagMapper.deleteByPrimaryKey(tagId);
    }

    @Override
    public List<YdTag> list(Map params) {
        return tagMapper.list(params);
    }
}
